package com.chandra.pos.customer.dao.entity;

import com.chandra.pos.common.model.POSConstant;
import com.chandra.pos.common.model.TransactionType;
import com.chandra.pos.common.utils.JodaDateTimeJsonSerializer;
import com.chandra.pos.common.utils.TrxJsonSerializer;
import org.codehaus.jackson.map.annotate.JsonSerialize;
import org.hibernate.annotations.Type;
import org.joda.time.DateTime;
import org.springframework.format.annotation.DateTimeFormat;

import javax.persistence.*;
import javax.validation.constraints.NotNull;

/**
 * Created by dnagarajan on 4/17/2015.
 * Maintain all the transaction done by the customer such as Sales order/Payments etc
 */

@Entity
@Table(name = "POS_TRANSACTIONS")
public class TransactionEntity {


    @Id
    @GeneratedValue(strategy = GenerationType.AUTO)
    @Column(name = "TRANSACTION_ID")
    private Long transactionId;

    @Column(name = "CUSTOMER_ID")
    private Long customerId;

    @Column(name = "CUSTOMER_NAME")
    private String customerName;


    @Column(name = "TRANSACTION_TYPE")
    @Enumerated(EnumType.STRING)
    @JsonSerialize(using = TrxJsonSerializer.class)
    private TransactionType transactionType;


    @NotNull
    @Type(type = "org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    @JsonSerialize(using = JodaDateTimeJsonSerializer.class)
    @DateTimeFormat(pattern = POSConstant.APP_DATE_FORMAT)
    private DateTime transactionDate ;

    @Column(name = "TRANSACTION_AMOUNT", unique = false, nullable = true)
    protected Double transactionAmount;

    @Column(name = "TRANSACTION_DETAIL_ID")
    private Long transactionDetailId;


    public Long getTransactionId() {
        return transactionId;
    }

    public void setTransactionId(Long transactionId) {
        this.transactionId = transactionId;
    }

    public Long getCustomerId() {
        return customerId;
    }

    public void setCustomerId(Long customerId) {
        this.customerId = customerId;
    }

    public Long getTransactionDetailId() {
        return transactionDetailId;
    }

    public void setTransactionDetailId(Long transactionDetailId) {
        this.transactionDetailId = transactionDetailId;
    }

    public TransactionType getTransactionType() {
        return transactionType;
    }

    public void setTransactionType(TransactionType transactionType) {
        this.transactionType = transactionType;
    }

    public Double getTransactionAmount() {
        return transactionAmount;
    }

    public void setTransactionAmount(Double transactionAmount) {
        this.transactionAmount = transactionAmount;
    }

    public DateTime getTransactionDate() {
        return transactionDate;
    }

    public void setTransactionDate(DateTime transactionDate) {
        this.transactionDate = transactionDate;
    }

    public String getCustomerName() {
        return customerName;
    }

    public void setCustomerName(String customerName) {
        this.customerName = customerName;
    }
}
